/*
 * ConditionalExpressionAst.h
 *
 *  Created on: 12 Nov 2010
 *      Author: kn308
 */

#ifndef CONDITIONALEXPRESSIONAST_H_
#define CONDITIONALEXPRESSIONAST_H_

#include <MAlice/Ast/ExpressionAst.h>
#include <MAlice/Ast/StatementAst.h>
#include <llvm/BasicBlock.h>
#include <llvm/Function.h>

namespace MAlice
{

class ConditionalExpressionAst: public ExpressionAst
{
protected:
	BasicBlock   * mMerge;
	Ast          * mBody;
	ExpressionAst* mCond;
	bool           mLast;

public:
	ConditionalExpressionAst(location loc, ExpressionAst* cond, Ast* stmt);

	virtual ~ConditionalExpressionAst();
	virtual llvm::Value* generate();

	inline void setLast(bool last)
	{
		mLast = last;
	}

	inline void setMerge(BasicBlock* bb)
	{
		mMerge = bb;
	}

	inline Ast* getBody()
	{
		return mBody;
	}

	inline ExpressionAst* getCondition()
	{
		return mCond;
	}
};


class UnConditionalExpressionAst: public ConditionalExpressionAst
{
public:
	UnConditionalExpressionAst(location loc, Ast* stmt);
	virtual ~UnConditionalExpressionAst();
	virtual llvm::Value* generate();
};

}

#endif /* CONDITIONALEXPRESSIONAST_H_ */
